﻿using System;
using System.Windows.Controls;
using System.Windows.Input;

namespace FrontDisplay.Controls
{
    /// <summary>
    /// Interaction logic for HotkeyControl.xaml
    /// </summary>
    public partial class HotkeyControl : UserControl
    {
        public HotkeyControl()
        {
            InitializeComponent();
            foreach (var item in Enum.GetValues(typeof(Key)))
            {
                KeyComboBox.Items.Add(item);
            }
        }

        public HotkeyInfo Value
        {
            get
            {
                return new HotkeyInfo
                    {
                        Win = WinCheckBox.IsChecked.Value,
                        Ctrl = CtrlCheckBox.IsChecked.Value,
                        Alt = AltCheckBox.IsChecked.Value,
                        Shift = ShiftCheckBox.IsChecked.Value,
                        Key = (Key) KeyComboBox.SelectedItem
                    };
            }
            set
            {
                Initialize(value);
            }
        }

        public void Initialize(HotkeyInfo hotkeyInfo)
        {
            WinCheckBox.IsChecked = hotkeyInfo.Win;
            CtrlCheckBox.IsChecked = hotkeyInfo.Ctrl;
            AltCheckBox.IsChecked = hotkeyInfo.Alt;
            ShiftCheckBox.IsChecked = hotkeyInfo.Shift;
            KeyComboBox.SelectedItem = hotkeyInfo.Key;
        }
    }
}
